<?php

namespace app\model;

use app\model\BaseModel;

/**
 * Role模型
 */
class Role extends BaseModel{
    protected function getOptions(): array{
        return [];
    }

    /**
     * 多对多 Role-User
     */
    public function roles(){
        return $this->belongsToMany(User::class, 'user_role', 'user_id', 'role_id');
    }

    /**
     * 多对多 Role-Permission
     */
    public function permissions(){
        return $this->belongsToMany(Permission::class, 'role_permission', 'permission_id', 'role_id');
    }
}